<template>
  <page-header-wrapper>
    <a-card :bordered="false">
      <div class="table-page-search-wrapper">
        <a-form layout="inline">
          <a-row :gutter="48">
          </a-row>
        </a-form>
      </div>

      <s-table
        ref="table"
        size="default"
        :rowKey="(record,index)=>{return index}"
        :columns="columns"
        :data="loadData"
        showPagination="auto"
      >
        <span slot="serial" slot-scope="text, record, index">
          {{ index + 1 }}
        </span>

        <span slot="action" slot-scope="text, record">
          <template>
            <a @click="handleEdit(record)" v-action:dashboard_watch2>查看</a>
          </template>
        </span>
      </s-table>

    </a-card>
    <a-card style="margin-top: 40px">
            <a-table :columns="columnson" :dataSource="loadDatas" :rowKey="(record,index)=>{return index}" :pagination="pagination">
          <a slot="name" slot-scope="text">{{ text }}</a>
          <span slot="serial" slot-scope="text, record, index">
          {{ index + 1 }}
        </span>
      </a-table>
    </a-card>
  </page-header-wrapper>
</template>

<script>
import { STable, Ellipsis } from '@/components'
import { GetStatus, GetItem} from '../../../api/school'

const columnson = [
  {
    title: '编号',
    scopedSlots: { customRender: 'serial' }
  },
  {
    title: '学校名称',
    dataIndex: 'schoolname',
  },
  {
    title: '联系人',
    dataIndex: 'contract'
  },
  {
    title: '电话',
    dataIndex: 'phone',
  },
  {
    title: '地址',
    dataIndex: 'address',
  },
  {
    title: '完成时间',
    dataIndex: 'finish_time',
  }
]

const columns = [
  {
    title: '编号',
    scopedSlots: { customRender: 'serial' }
  },
  {
    title: '发布人',
    dataIndex: 'username',
  },
  {
    title: ' 任务名称',
    dataIndex: 'task_name',
  },
  {
    title: '发布时间',
    dataIndex: 'release_time',
  },
  {
    title: '截止时间',
    dataIndex: 'endtime',
  },
  {
    title: '任务类别',
    dataIndex: 'taskcate_id',
  },
  {
    title: '任务描述',
    dataIndex: 'descs',
  },
  {
    title: '任务目标',
    dataIndex: 'task_target',
  },
  {
    title: '任务分类',
    dataIndex: 'title',
  },
  {
    title: '完成数量',
    dataIndex: 'finish_num',
  },
  {
    title: '操作',
    dataIndex: 'action',
    width: '120px',
    scopedSlots: { customRender: 'action' }
  }
]
export default {
  name: 'school',
  components: {
    STable,
    Ellipsis,
  },
  data () {
    this.columns = columns
    this.columnson = columnson
    return {
      pagination:{
        defaultPageSize:5,
        showTotal: total => `共 ${total} 条数据`,
        showSizeChanger:false,
        pageSizeOptions: ['5', '10', '15', '20'],
        onShowSizeChange:(current, pageSize)=>this.pageSize = pageSize
        },
      // 标签展示
      // 监督员展示
      // 多选按钮id
      // 树选择列表
      // 查询参数
      queryParam: {},
      loadDatas: [],
      // 加载数据方法 必须为 Promise 对象
      loadData: parameter => {
        const requestParameters = Object.assign({}, parameter, this.queryParam, {role_type: localStorage.getItem('role_type')})
        console.log('loadData request parameters:', requestParameters)
        return GetStatus(requestParameters)
          .then(res => {
            return res.data
          }, error => {
            this.$router.push('/user/login');
          })
      }
    }
  },
  created() {
  },
  methods: {
    // 获取列表
      handleEdit (record) {
      GetItem({ id: record.id, emdtime: record.emdtime}).then(res => {
        this.loadings = false
        if(res.data.length > 0) {
          this.loadDatas = res.data
        } else {
          this.loadDatas = []
        }
      })
    },
    // 获取学校标签列表
    // 获取用户数据
    // 树下拉列表
    // 获取多选列表
    // 创建
    // 删除
    // 启用 
    // 禁用
    // 重置
    // 搜素模糊查询
  }
}
</script>
